var mysql = require('./mysql');
exports.login = function(data){
    var that = this;

    mysql.runQuery('SELECT * FROM users where username = ? and password = ?',
        [data.sendUsername, data.sendPassword], function(err, rows){
            if (rows.length === 0) {
                that.emit("checkLogin", { error: 'wrong username or password', allUser: null });
            } else {
                mysql.runQuery('SELECT * FROM users', function(err, rows){
                    that.emit("checkLogin", { error: 'success', allUser: rows });
                });
            }
        });
};
